Multi Team: Automatically create and assign team default pools#69768
Multi Team: Automatically create and assign team default pools#69768SameerMesiah97 wants to merge 4 commits into
Conversation
4c57afb to
9691842
Compare
9691842 to
fdcf3d6
Compare
fdcf3d6 to
9572e56
Compare
|
Tagging you here as this is your domain i.e. multi-team. |
| ): | ||
| associations.append(f"{pool_count} pool(s)") | ||
|
|
||
| default_pool = session.scalar(select(Pool).where(Pool.pool == Pool.get_default_team_pool_name(team.name))) |
There was a problem hiding this comment.
That's an edge case but could be named default_pool_marketing and be global. We should check that the pool is also associated to the team
There was a problem hiding this comment.
And additional check has been added to the where clause to ensure that the select pool is associated with the team.
o-nikolas
left a comment
There was a problem hiding this comment.
Thanks for the contribution! The code needs a fair amount of work but I like the idea!
| The specified team must exist in the database (create it first with ``airflow teams create``). | ||
|
|
||
| When ``core.multi_team`` is enabled, ``airflow teams create`` automatically | ||
| creates a default pool named ``default_pool_<team_name>``. Tasks in DAG |
There was a problem hiding this comment.
| creates a default pool named ``default_pool_<team_name>``. Tasks in DAG | |
| creates a default pool named ``default_pool_<team_name>``. Tasks in Dag |
There was a problem hiding this comment.
Should it not be DAG instead of Dag as it is an acronym?
Edit: Nvm, it appears that 'Dag' is the convention in the docs.
|
|
||
| When ``core.multi_team`` is enabled, ``airflow teams create`` automatically | ||
| creates a default pool named ``default_pool_<team_name>``. Tasks in DAG | ||
| bundles associated with that team that do not explicitly specify a pool will |
There was a problem hiding this comment.
| bundles associated with that team that do not explicitly specify a pool will | |
| bundles associated with that team which do not explicitly specify a pool will |
There was a problem hiding this comment.
I am not sure if 'which' is more gramatically correct than 'that' here as the part after is necessary for the sentence to communicate the complete idea. Regardless, I have rephrased this part for clarity.
| bundles associated with that team that do not explicitly specify a pool will | ||
| use the team's default pool automatically. | ||
|
|
||
| Existing multi-team deployments should run ``airflow teams sync`` after upgrading |
There was a problem hiding this comment.
Multi-team is in experimental phase right now. I'm not sure we want to a very time based piece in our docs. Update the news fragment to call out this guidance about syncing existing multi-team deployments.
| default_pool = session.scalar(select(Pool).where(Pool.pool == Pool.get_default_team_pool_name(team.name))) | ||
|
|
||
| if default_pool: | ||
| session.delete(default_pool) |
There was a problem hiding this comment.
This delete is happening way too soon. There is a check below "are you sure you want to delete..." you should not delete anything until after that.
There was a problem hiding this comment.
This has been moved down to the try/except block where team deletion is attempted.
| slots=conf.getint( | ||
| "core", | ||
| "default_pool_task_slot_count", | ||
| ), |
There was a problem hiding this comment.
This clobbers any specific pool slots admins may have set if the pool already exists. You really just want create if missing not create or update
There was a problem hiding this comment.
We are now querying for an existing default pool and creating it only if no pool is found.
| with conf_vars( | ||
| { | ||
| ("core", "multi_team"): "True", | ||
| ("multi_team", "default_pool_task_slot_count"): "128", |
There was a problem hiding this comment.
| ("multi_team", "default_pool_task_slot_count"): "128", | |
| ("core", "default_pool_task_slot_count"): "111", |
This is a core config, and the default is already 128, setting it to something else ensures that this is working in your test.
6caec49 to
4ff010e
Compare
4ff010e to
c4de299
Compare
assign tasks without an explicit pool to the team's default pool during DAG parsing. Add unit tests covering pool assignment and team creation, and update the multi-team documentation to describe the new behaviour.
…missing pools for existing teams. Automatically remove the system-managed default team pool during while preserving protection for user-created team pools. Add tests covering reconciliation and cleanup.
…ct config key in test.
c4de299 to
88dc14b
Compare
Only create missing default team pools during teams sync, improve cleanup during team deletion, and update the documentation and tests.
88dc14b to
1ca0fb1
Compare
Description
This change introduces automatic default pool management for multi-team deployments.
With this implementation, a corresponding default pool named
default_pool_<team_name>is automatically created on team creation. During DAG parsing, tasks that do not explicitly specify a pool are assigned to their team's default pool based on the DAG bundle association, while tasks with explicitly configured pools are left unchanged.The implementation also extends the team management commands so that
teams syncreconciles missing default team pools for existing teams, andteams deleteautomatically removes the system-managed default team pool.Rationale
In multi-team deployments, tasks without an explicit pool are currently assigned to the global
default_pool, allowing one team's workload to consume capacity shared across all teams. Avoiding this requires users to manually create and configure team-specific pools and update every task to reference them.By automatically provisioning a per-team default pool and applying it during DAG parsing, Airflow provides sensible defaults while preserving explicit pool assignments. This reduces operational overhead and helps isolate execution capacity between teams without requiring changes to existing DAGs.
Tests
Added unit tests verifying that:
default_poolare assigned to the appropriate team default pool during DAG parsing.default_pool.teams syncrecreates missing default team pools for existing teams.Documentation
Updated the multi-team documentation to describe automatic creation of team default pools and how they are applied during DAG parsing.
Backwards Compatibility
Existing behaviour is preserved when multi-team mode is disabled. Tasks with explicitly configured pools continue to use their configured pool without modification.
Closes: #69170